package cn.flyboy.test;

import cn.flyboy.entity.StaticResources;
import cn.flyboy.utils.XMLHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

//作为Spring Test的类
@RunWith(SpringJUnit4ClassRunner.class)
//加载配置文件
@ContextConfiguration(locations = "classpath:spring/spring.xml")

public class testSysSetting {

    //读取全局设置信息
    @Test
    public void testSettings() {
        String path = System.getProperty("user.dir") + "/src/main/webapp/assets/config.xml";

        //测试读取
        Map<String, String> config = new HashMap<>();
        config.put(StaticResources.SPLIT_PAGE_COUNT, "" + 10);
        try {
            XMLHelper.updateXml(path, config);
            XMLHelper.xmlToMap(path);
        } catch (IOException e) {
            System.out.println("更新配置文件失败");
            e.printStackTrace();
        }
    }
}
